home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2001 September / PC-WELT 9-2001.ISO / software / hw / brennen / flask_src.exe / Input / IFOParser / ifo.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-11  |  6.5 KB  |  274 lines

  1. #ifndef __IFO_H__
  2. #define __IFO_H__
  3.  
  4. #ifndef DVD_VIDEO_LB_LEN
  5. #define DVD_VIDEO_LB_LEN 2048
  6. #endif
  7.  
  8. typedef unsigned int  u_int;
  9. typedef unsigned char u_char;
  10. typedef unsigned short u_short;
  11. typedef unsigned long  u_long;
  12. typedef unsigned int   u_int32_t;
  13. typedef unsigned short u_int16_t;
  14. typedef unsigned __int64 __off64_t;
  15. /**
  16.  * Video Info Table 
  17.  */
  18. #define LITTLE_ENDIAN 0x45
  19. #define BYTE_ORDER LITTLE_ENDIAN
  20.  
  21. typedef struct {
  22. #if BYTE_ORDER == BIG_ENDIAN
  23.     u_char compression      : 2;
  24.     u_char system           : 2;
  25.     u_char ratio            : 2;
  26.     u_char perm_displ       : 2;
  27.  
  28.     u_char line21_1         : 1;
  29.     u_char line21_2         : 1;
  30.     u_char source_res       : 2;
  31.     u_char letterboxed      : 1;
  32.     u_char mode             : 1;
  33. #else
  34.     u_char perm_displ       : 2;
  35.     u_char ratio            : 2;
  36.     u_char system           : 2;
  37.     u_char compression      : 2;
  38.  
  39.     u_char mode             : 1;
  40.     u_char letterboxed      : 1;
  41.     u_char source_res       : 2;
  42.     u_char line21_2         : 1;
  43.     u_char line21_1         : 1;
  44. #endif
  45. } ifo_video_info_t;
  46.  
  47. /**
  48.  * Audio Table
  49.  */
  50.    
  51. typedef struct {
  52. #if BYTE_ORDER == LITTLE_ENDIAN
  53.     u_char num_channels    : 3;    // number of channels (n+1)
  54.     u_char sample_freq    : 2;    // sampling frequency
  55.     u_char quantization    : 2;    // quantization
  56.     u_char appl_mode2    : 1;    // audio application mode
  57.  
  58.     u_char appl_mode1    : 1;    // 
  59.     u_char type        : 2;    // audio type (language included?)
  60.     u_char multichannel_extension: 1;
  61.     u_char coding_mode    : 4; 
  62. #else
  63.     u_char appl_mode2    : 1;
  64.     u_char quantization    : 2;
  65.     u_char sample_freq    : 2;
  66.     u_char num_channels    : 3;
  67.  
  68.     u_char coding_mode    : 4;
  69.     u_char multichannel_extension: 1;
  70.     u_char type        : 2;
  71.     u_char appl_mode1    : 1;
  72. #endif
  73.     u_short lang_code    : 16;   // <char> description
  74.     u_int   foo        : 8;    // 0x00000000 ?
  75.     u_int   caption        : 8;
  76.     u_int   bar        : 8;    // 0x00000000 ?
  77. } ifo_audio_t;
  78.  
  79. #define IFO_AUDIO_LEN 7
  80.  
  81. /**
  82.  * Subpicture Table
  83.  */
  84.  
  85. typedef struct {
  86.     u_short prefix  : 16;           // 0x0100 ?
  87.     u_short lang_code : 16;         // <char> description
  88.     u_char foo      : 8;            // dont know
  89.     u_char caption  : 8;            // 0x00 ?
  90. } ifo_spu_t;
  91.  
  92.  
  93. /**
  94.  * Time Map Table header entry
  95.  */
  96.  
  97. #if 0
  98. typedef struct {
  99.     u_char  tu        : 16;    // time unit (in seconds)
  100.     u_int            : 16;   // don't know
  101. } ifo_tmt_hdr_t;
  102. #endif
  103.  
  104. typedef struct {
  105.     u_int            : 24;   // don't know
  106.     u_char  tu        : 8;    // time unit (in seconds)
  107. } ifoq_tmt_hdr_t;
  108.  
  109. //#define IFO_TMT_HDR_LEN 4
  110. #define IFOQ_TMT_HDR_LEN 1
  111.  
  112.  
  113. /**
  114.  * hmm
  115.  */
  116.  
  117. typedef struct {
  118.         u_short vob_id          : 16;   // Video Object Identifier
  119.         u_char  cell_id         : 8;    // Cell Identifier
  120.         u_char                  : 8;    // don't know
  121.         u_int   start           : 32;   // Cell start
  122.         u_int   end             : 32;   // Cell end
  123. } ifo_cell_addr_t;
  124.  
  125.  
  126. typedef struct {
  127.     u_short vob_id        : 16;    // Video Object Identifier
  128.     u_short cell_id        : 16;    // Cell Identifier
  129. } ifo_pgc_cell_pos_t;
  130.  
  131. /**
  132.  * Part of Title AND Title set Cell Address
  133.  */
  134.  
  135. typedef struct {
  136.     u_short pgc;        // Program Chain (PTT)
  137.     u_short pg;        // Program (PTT)
  138.     u_long    start;        // Start of VOBU (VTS? CADDR)
  139.     u_long    end;        // End of VOBU (VTS? CADDR)
  140. } ifo_ptt_data_t;
  141.  
  142. typedef struct {
  143.     u_int num;        // Number of Chapters
  144.     ifo_ptt_data_t *data;    // Data
  145. } ifo_ptt_sub_t;
  146.  
  147. typedef struct {
  148.     u_int num;        // Number of Titles
  149.     ifo_ptt_sub_t *title;    // Titles
  150. } ifo_ptt_t;
  151.  
  152. typedef struct {
  153.         u_int   foo             : 32;
  154.         u_int   len_time        : 32;
  155.         u_int   vobu_start      : 32;   // 1st vobu start
  156.         u_int   ilvu_end        : 32;
  157.         u_int   vobu_last_start : 32;
  158.         u_int   vobu_last_end   : 32;
  159. } ifo_pgci_cell_addr_t;
  160.  
  161. #define PGCI_CELL_ADDR_LEN 24
  162.  
  163. #define ID_NUM_MENU_VOBS 0
  164. #define ID_NUM_TITLE_VOBS 1
  165.  
  166. #define ID_MAT            0
  167. #define ID_PTT            1
  168. #define ID_TITLE_PGCI        2
  169. #define ID_MENU_PGCI        3
  170. #define ID_TMT            4
  171. #define ID_MENU_CELL_ADDR    5
  172. #define ID_MENU_VOBU_ADDR_MAP    6
  173. #define ID_TITLE_CELL_ADDR    7
  174. #define ID_TITLE_VOBU_ADDR_MAP     8
  175.  
  176.  
  177. /**
  178.  * Information Table - for internal use only
  179.  */
  180.  
  181. typedef struct {
  182.     u_int num_menu_vobs;
  183.     u_int vob_start;
  184.  
  185.     u_char *data[10];
  186.     
  187.     int fd;        // file descriptor
  188.     __off64_t pos;    // offset of ifo file on device 
  189. } ifo_t;
  190.  
  191.  
  192. /**
  193.  * Generic header
  194.  */
  195.  
  196. #define IFO_HDR_LEN 8
  197. #define IFOQ_HDR_LEN 2
  198.  
  199. typedef struct {
  200.         u_short num     : 16;   // number of entries
  201.         u_short         : 16;   // don't known (reserved?)
  202.         u_int   len     : 32;   // length of table
  203. } ifo_hdr_t;
  204.  
  205. typedef struct {
  206.         u_short         : 16;   // don't known (reserved?)
  207.         u_short num     : 16;   // number of entries
  208.         u_int   len     : 32;   // length of table
  209. } ifoq_hdr_t;
  210.  
  211.  
  212. /**
  213.  * Prototypes
  214.  */
  215.  
  216. ifo_t *ifoOpen (int fd, __off64_t pos);
  217. int ifoClose (ifo_t *ifo);
  218.  
  219. int ifoGetVOBStart    (ifo_t *ifo);
  220. int ifoGetNumberOfTitles (ifo_t *ifo);
  221. int ifoGetNumberOfParts (ifo_t *ifo);
  222.  
  223. int ifoGetVMGPTT    (ifo_hdr_t *hdr, char **ptr);
  224. int ifoGetPGCI        (ifo_hdr_t *hdr, int title, char **ptr);
  225. int ifoGetCLUT        (char *pgc, char **ptr);
  226. int ifoGetCellPlayInfo    (char *pgc, char **ptr);
  227. int ifoGetCellPos    (char *pgc, char **ptr);
  228. int ifoGetProgramMap    (char *pgc, char **ptr);
  229. int ifoGetCellAddr    (char *cell_addr, char **ptr);
  230. int ifoGetCellAddrNum    (char *hdr);
  231.  
  232. int ifoGetAudio        (char *hdr, char **ptr);
  233. int ifoGetSPU        (char *hdr, char **ptr);
  234.  
  235. ifo_ptt_t *ifo_get_ptt (ifo_t *ifo);
  236. int ifo_get_num_title_pgci (ifo_t *ifo);
  237. u_char *ifo_get_ptr_title_pgci (ifo_t *ifo, int index);
  238.  
  239. char *ifoDecodeLang (u_short descr);
  240.  
  241. int ifoIsVTS (ifo_t *ifo);
  242. int ifoIsVMG (ifo_t *ifo);
  243.  
  244. void ifoPrintVideo        (u_char *ptr);
  245.  
  246. void ifoPrintCellPlayInfo    (u_char *ptr, u_int num);
  247. void ifoPrintCellInfo        (u_char *ptr, u_int num);
  248. void ifoPrintCellPos        (u_char *ptr, u_int num);
  249. void ifoPrintCLUT        (u_char *ptr); 
  250. void ifoPrintProgramMap        (u_char *ptr, u_int num);
  251.  
  252. #ifdef PARSER
  253. void ifoPrintAudio        (ifo_audio_t *ptr, u_int num);
  254. void ifoPrintSPU        (ifo_spu_t *ptr, u_int num);
  255. void ifoPrintTMT        (ifo_t *ifo);
  256.  
  257. void ifoPrintVMOP        (u_char *opcode);
  258.  
  259. void ifoPrint_ptt (ifo_ptt_t *ptt);
  260. void ifoPrint_vts_vobu_addr_map (ifo_t *ifo);
  261. void ifoPrint_vtsm_vobu_addr_map (ifo_t *ifo);
  262. void ifoPrint_vts_cell_addr (ifo_t *ifo);
  263. void ifoPrint_vtsm_cell_addr (ifo_t *ifo);
  264. void ifoPrint_title_pgci (ifo_t *ifo);
  265. void ifoPrint_pgc_cmd (u_char *pgc_ptr);
  266. void ifoPrintToast (u_char *toast);
  267. void ifoPrint_pgc (u_char *ptr);
  268. #endif
  269.  
  270. //DENT move this out
  271. #include "misc.h"
  272. #endif
  273.  
  274.